﻿using System;
using System.IO;
using Hongsh.Pay.Client.Proxy.Http;
using MapleLeaf.Pay;

namespace Hongsh.Pay.Client.Proxy.Handlers
{
	// Token: 0x0200004A RID: 74
	public static class BWPayProxy
	{
		// Token: 0x06000244 RID: 580 RVA: 0x000037AD File Offset: 0x000019AD
		public static void AddBWPayProxyHandler(this HttpServer svr)
		{
			svr.RouterList.Add("GET/bwpaysrv.ashx", new HttpContextActionDelegate(Init));
			svr.RouterList.Add("POST/bwpaysrv.ashx", new HttpContextActionDelegate(Init));
		}

		// Token: 0x06000245 RID: 581 RVA: 0x0000D5D0 File Offset: 0x0000B7D0
		private static void Init(HttpContext ctx)
		{
			string text = new StreamReader(ctx.Request).ReadToEnd();
			if (text.StartsWith(BWPayInitParamHeader, StringComparison.OrdinalIgnoreCase))
			{
				string text2 = System.Web.HttpUtility.UrlDecode(text.Substring(BWPayInitParamHeader.Length));
				if (text2.Length > 0)
				{
                    BWPayRequest bwpayRequest = text2.JsonDecode<BWPayRequest>();
					object content;
					if (bwpayRequest.sAction.Contains("gettoken"))
					{
						content = new Class13 {
							custNo = bwpayRequest.sBwNo,
							merchant_name = bwpayRequest.sBranchName,
							custApiKey = "1FC0E1ABE3927B559E2741BF0E898214",
							custFlow = "11412031",
							bResult = "True",
							custRateType = "t1",
							sToken = "UBN0JwKJT_acUeDxN1eGNg~~",
							ysf_merid = "M2012011115515097187",
							payinc_id = "1",
							ypay_apikey = "1234",
							ypay_custno = "101112",
							ypay_pwd = "1234"
						};
					}
					else
					{
						content = new
						{
							bResult = true,
							errMsg = ""
						};
					}
					ctx.Result = new HttpJsonResult(content);
				}
			}
			if (ctx.Result == null)
			{
				ctx.Result = new HttpHtmlResult("威支付!");
			}
		}

		// Token: 0x06000246 RID: 582 RVA: 0x000037E7 File Offset: 0x000019E7
		static BWPayProxy()
		{
			//Class15.cwcZ3SWztHroi();
            BWPayInitParamHeader = "sParam=";
		}

		// Token: 0x040000F5 RID: 245
		private static string BWPayInitParamHeader;

		// Token: 0x0200004B RID: 75
		private class BWPayRequest
		{
			// Token: 0x170000F8 RID: 248
			// (get) Token: 0x06000247 RID: 583 RVA: 0x000037F8 File Offset: 0x000019F8
			// (set) Token: 0x06000248 RID: 584 RVA: 0x00003800 File Offset: 0x00001A00
			public string sAction { get; set; }

			// Token: 0x170000F9 RID: 249
			// (get) Token: 0x06000249 RID: 585 RVA: 0x00003809 File Offset: 0x00001A09
			// (set) Token: 0x0600024A RID: 586 RVA: 0x00003811 File Offset: 0x00001A11
			public string sBranchName { get; set; }

			// Token: 0x170000FA RID: 250
			// (get) Token: 0x0600024B RID: 587 RVA: 0x0000381A File Offset: 0x00001A1A
			// (set) Token: 0x0600024C RID: 588 RVA: 0x00003822 File Offset: 0x00001A22
			public string sBwNo { get; set; }

			// Token: 0x0600024D RID: 589 RVA: 0x0000286D File Offset: 0x00000A6D
			public BWPayRequest()
			{
				//Class15.cwcZ3SWztHroi();
				//base..ctor();
			}
		}

		// Token: 0x0200004C RID: 76
		private class Class13
		{
			// Token: 0x170000FB RID: 251
			// (get) Token: 0x0600024E RID: 590 RVA: 0x0000382B File Offset: 0x00001A2B
			// (set) Token: 0x0600024F RID: 591 RVA: 0x00003833 File Offset: 0x00001A33
			public string branchName { get; set; }

			// Token: 0x170000FC RID: 252
			// (get) Token: 0x06000250 RID: 592 RVA: 0x0000383C File Offset: 0x00001A3C
			// (set) Token: 0x06000251 RID: 593 RVA: 0x00003844 File Offset: 0x00001A44
			public string branchNo { get; set; }

			// Token: 0x170000FD RID: 253
			// (get) Token: 0x06000252 RID: 594 RVA: 0x0000384D File Offset: 0x00001A4D
			// (set) Token: 0x06000253 RID: 595 RVA: 0x00003855 File Offset: 0x00001A55
			public string bResult { get; set; }

			// Token: 0x170000FE RID: 254
			// (get) Token: 0x06000254 RID: 596 RVA: 0x0000385E File Offset: 0x00001A5E
			// (set) Token: 0x06000255 RID: 597 RVA: 0x00003866 File Offset: 0x00001A66
			public string custApiKey { get; set; }

			// Token: 0x170000FF RID: 255
			// (get) Token: 0x06000256 RID: 598 RVA: 0x0000386F File Offset: 0x00001A6F
			// (set) Token: 0x06000257 RID: 599 RVA: 0x00003877 File Offset: 0x00001A77
			public string custFlow { get; set; }

			// Token: 0x17000100 RID: 256
			// (get) Token: 0x06000258 RID: 600 RVA: 0x00003880 File Offset: 0x00001A80
			// (set) Token: 0x06000259 RID: 601 RVA: 0x00003888 File Offset: 0x00001A88
			public string custNo { get; set; }

			// Token: 0x17000101 RID: 257
			// (get) Token: 0x0600025A RID: 602 RVA: 0x00003891 File Offset: 0x00001A91
			// (set) Token: 0x0600025B RID: 603 RVA: 0x00003899 File Offset: 0x00001A99
			public string custRateType { get; set; }

			// Token: 0x17000102 RID: 258
			// (get) Token: 0x0600025C RID: 604 RVA: 0x000038A2 File Offset: 0x00001AA2
			// (set) Token: 0x0600025D RID: 605 RVA: 0x000038AA File Offset: 0x00001AAA
			public string errMsg { get; set; }

			// Token: 0x17000103 RID: 259
			// (get) Token: 0x0600025E RID: 606 RVA: 0x000038B3 File Offset: 0x00001AB3
			// (set) Token: 0x0600025F RID: 607 RVA: 0x000038BB File Offset: 0x00001ABB
			public string merchant_name { get; set; }

			// Token: 0x17000104 RID: 260
			// (get) Token: 0x06000260 RID: 608 RVA: 0x000038C4 File Offset: 0x00001AC4
			// (set) Token: 0x06000261 RID: 609 RVA: 0x000038CC File Offset: 0x00001ACC
			public string operGrant { get; set; }

			// Token: 0x17000105 RID: 261
			// (get) Token: 0x06000262 RID: 610 RVA: 0x000038D5 File Offset: 0x00001AD5
			// (set) Token: 0x06000263 RID: 611 RVA: 0x000038DD File Offset: 0x00001ADD
			public string operName { get; set; }

			// Token: 0x17000106 RID: 262
			// (get) Token: 0x06000264 RID: 612 RVA: 0x000038E6 File Offset: 0x00001AE6
			// (set) Token: 0x06000265 RID: 613 RVA: 0x000038EE File Offset: 0x00001AEE
			public string payinc_id { get; set; }

			// Token: 0x17000107 RID: 263
			// (get) Token: 0x06000266 RID: 614 RVA: 0x000038F7 File Offset: 0x00001AF7
			// (set) Token: 0x06000267 RID: 615 RVA: 0x000038FF File Offset: 0x00001AFF
			public string sToken { get; set; }

			// Token: 0x17000108 RID: 264
			// (get) Token: 0x06000268 RID: 616 RVA: 0x00003908 File Offset: 0x00001B08
			// (set) Token: 0x06000269 RID: 617 RVA: 0x00003910 File Offset: 0x00001B10
			public string userName { get; set; }

			// Token: 0x17000109 RID: 265
			// (get) Token: 0x0600026A RID: 618 RVA: 0x00003919 File Offset: 0x00001B19
			// (set) Token: 0x0600026B RID: 619 RVA: 0x00003921 File Offset: 0x00001B21
			public string ysf_merid { get; set; }

			// Token: 0x1700010A RID: 266
			// (get) Token: 0x0600026C RID: 620 RVA: 0x0000392A File Offset: 0x00001B2A
			// (set) Token: 0x0600026D RID: 621 RVA: 0x00003932 File Offset: 0x00001B32
			public string ypay_apikey { get; set; }

			// Token: 0x1700010B RID: 267
			// (get) Token: 0x0600026E RID: 622 RVA: 0x0000393B File Offset: 0x00001B3B
			// (set) Token: 0x0600026F RID: 623 RVA: 0x00003943 File Offset: 0x00001B43
			public string ypay_custno { get; set; }

			// Token: 0x1700010C RID: 268
			// (get) Token: 0x06000270 RID: 624 RVA: 0x0000394C File Offset: 0x00001B4C
			// (set) Token: 0x06000271 RID: 625 RVA: 0x00003954 File Offset: 0x00001B54
			public string ypay_pwd { get; set; }

			// Token: 0x06000272 RID: 626 RVA: 0x0000286D File Offset: 0x00000A6D
			public Class13()
			{
				//Class15.cwcZ3SWztHroi();
				//base..ctor();
			}
		}
	}
}
